package wode.view;
import wode.entity.CreateEnemy;
import wode.entity.EnemyPlane;
import wode.entity.FightePlane;
import wode.utils.p;
import javax.swing.*;
import java.awt.*;
import java.util.LinkedList;
import java.util.List;

//这个类是关于游戏界面的
public class GamePanel extends JPanel{
    public static List<EnemyPlane> arrayList1=new LinkedList<EnemyPlane>();
    private FightePlane fightePlane;
        public GamePanel(FightePlane fightePlane){
            this.fightePlane=fightePlane;
            new updateGame().start();
            new CreateEnemy().start();
        }
    boolean flage=true;
    public void paint(Graphics g) {//Graphics 是一个画笔工具
        g.setColor(Color.black);//设置背景颜色
        g.fillRect(0, 0, p.width, p.height);//设置颜色填充效果
        if (fightePlane != null) {
            fightePlane.drawMe(g);//画出战斗机
        }
        for (int i = 0; i < arrayList1.size(); i++) {
            arrayList1.get(i).drawMe(g);
        }
    }
    class updateGame extends Thread{
        public void run(){
            while (flage){
                repaint();
            }
        }
    }
}